import Vue from 'vue'
import VueRouter from 'vue-router'
import leftNav from './leftNav.js'
import Layout from '@/layout/index.vue'

// pc端
const routers = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/',
    name: 'layout',
    component: Layout,
    meta: { title: '绩效系统', icon: 'icon-a-shouye', affix: true },
    children: [...leftNav]
  },
  // 登录begin
  {
    path: '/login',
    name: 'login',
    meta: {
      title: '登录'
    },
    component: () => import('@/views/login/index.vue')
  }
  // 登录end
]

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const router = new VueRouter({
  routes: routers
})

export default router
